﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Comm;

public partial class user_register : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnReg_Click(object sender, EventArgs e)
    {
        string name = txtName.Text.Trim();
        string email = txtEmail.Text.Trim();
        string password = txtPssword.Text.Trim();
        string code = txtCode.Text.Trim();
        if (!txt_YanCodeImage.Equals(code))
        {
            MessageBox.Show("抱歉，验证码错误。");
        }
        else
        {
            BLL.User bll = new BLL.User();
            Model.User user = bll.GetModelBystrWhere(string.Format(" UserName='{0}' ", name));
            if (user == null)
            {
                Model.User u = new Model.User();
                u.UserName = name;
                u.PassWord = password;
                u.Email = email;
                if (bll.Add(u) > 0)
                {
                    CnGine.Comm.MessageBox.AlertAndRedirect("注册成功，请登录！", "login.aspx", this.Page);
                }
                else
                {
                    CnGine.Comm.MessageBox.Alert("请稍后重试！", this.Page);
                }
            }
            else
            {
                CnGine.Comm.MessageBox.Alert("账号已存在，请重新输入！", this.Page);
            }
        }

    }
}